package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.List;

import com.xcity.db.entity.Guild;
import com.xcity.db.entity.GuildMember;
import com.xcity.game.guild.template.GuildDonateTemplate;

import naga.x.game.time.TimeUpdater;
import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class GuildViewDonateResponse extends Response {

	private int level;
	private int curExp;
	private int maxExp;
	private List<GuildMemberDonateInfo> donates;
	public static class GuildMemberDonateInfo{
		public int type;
		public int exp;
		public int score;
		public int vip;
		public int stone;
		public int count;
		public GuildMemberDonateInfo(GuildDonateTemplate temp, int docount){
			this.type = temp.getType();
			this.exp = temp.getExp();
			this.score = temp.getScore();
			this.vip = temp.getNeedvip();
			this.stone = temp.getStone();
			this.count = temp.getMax() - docount;
			if(this.count < 0){
				this.count = 0;
			}
		}
	}
	
	public GuildViewDonateResponse(int serial, Guild guild, int lvl, int showCur, int showNeed, List<GuildDonateTemplate> list, GuildMember member) {
		super(serial);
		this.level = lvl;
		this.curExp = showCur;
		this.maxExp = showNeed;
		this.donates = new ArrayList<GuildMemberDonateInfo>();
		int today = TimeUpdater.getInstance().today();
		for(int i = 0, size = list.size(); i < size; i++){
			GuildDonateTemplate tmp = list.get(i);
			if(tmp.getMax() > 0){
				int doCount = member.getMemData().getDonateCountToday(tmp.getType(), today);
				if(doCount > -1){
					this.donates.add(new GuildMemberDonateInfo(tmp, doCount));
				}
			}
		}
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public int getCurExp() {
		return curExp;
	}

	public void setCurExp(int curExp) {
		this.curExp = curExp;
	}

	public int getMaxExp() {
		return maxExp;
	}

	public void setMaxExp(int maxExp) {
		this.maxExp = maxExp;
	}

	public List<GuildMemberDonateInfo> getDonates() {
		return donates;
	}

	public void setDonates(List<GuildMemberDonateInfo> donates) {
		this.donates = donates;
	}
}
